﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using Celerity.ColourPalette;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Celerity.Content
{
    public static class ImageLibrary
    {
        #region Instance Variables
        // Gfx
        static GraphicsDevice graphics;

        // 3D
        public static Texture2D TunnelTexture;

        // Misc
        public static Texture2D GameOverFace;
        public static Texture2D Logo;

        // Flat Textures
        public static Texture2D TextureAccent;
        public static Texture2D TextureAccentPressed;
        public static Texture2D TextureWhite;
        public static Texture2D TextureGrey;

        // Input
        public static Texture2D InputKeys;
        public static Texture2D InputGamepad;
        public static Texture2D InputTilt;

        // Play
        public static Texture2D PlayBar;

        // About
        public static Texture2D About;

        // Controls
        public static Texture2D ControlsIconNoGamepad;
        public static Texture2D ControlsIconYesGamepad;
        public static Texture2D ControlsIconNoWebcam;
        public static Texture2D ControlsIconYesWebcam;
        public static Texture2D ControlsIconNoKeyboard;
        public static Texture2D ControlsIconYesKeyboard;
        public static Texture2D ControlsIconNoGyro;
        public static Texture2D ControlsIconYesGyro;

        // Controls
        public static Texture2D CreatorPortraits;

        // Status Icons
        public static Texture2D IconBomb;
        public static Texture2D IconHeart;

        // Back Icons
        public static Texture2D IconBack;
        public static Texture2D IconBackPressed;

        // Mute Icons
        public static Texture2D IconMuteMute;
        public static Texture2D IconMuteMutePressed;
        public static Texture2D IconMuteUnmute;
        public static Texture2D IconMuteUnmutePressed;

        // Close Icons
        public static Texture2D IconClose;
        public static Texture2D IconClosePressed;

        // Mouse Cursor Icons
        public static Texture2D Mouse;

        // Webcam UI
        public static Texture2D FaceBlob;
        public static Texture2D Webcam;
        public static Texture2D CalibratorBorder;
        public static Texture2D CalibratorTarget;
        public static Texture2D CalibratorCrossHairs;
        #endregion /Instance Variables

        public static void Load(GraphicsDevice graphicsDevice)
        {
            // Keep graphics device for Get functions
            graphics = graphicsDevice;

            // Flat Textures ()
            TextureAccent = new Texture2D(graphics, 1, 1);
            TextureAccent.SetData(new[] { Palette.Accent });
            TextureAccentPressed = new Texture2D(graphics, 1, 1);
            TextureAccentPressed.SetData(new[] { Palette.AccentPressed });
            TextureWhite = new Texture2D(graphics, 1, 1);
            TextureWhite.SetData(new[] { Color.White });
            TextureGrey = new Texture2D(graphics, 1, 1);
            TextureGrey.SetData(new[] { Palette.OverlayGrey });

            // Tunnel Panel Texture
            TunnelTexture = Get(ResxImg.TunnelTexture);

            // Webcam Missing
            FaceBlob = Get(ResxImg.FaceBlob);
            Webcam = Get(ResxImg.Webcam);

            // Calibrator
            CalibratorBorder = Get(ResxImg.CalibratorBorder);
            CalibratorTarget = Get(ResxImg.CalibratorTarget);
            CalibratorCrossHairs = Get(ResxImg.CalibratorCrossHairs);

            // Game over
            GameOverFace = Get(ResxImg.GameOverFace);

            // Logo
            Logo = Get(ResxImg.Logo);

            // Play
            PlayBar = Get(ResxImg.PlayBar);

            // About
            About = Get(ResxImg.About);

            // Mouse
            Mouse = Get(ResxImg.Mouse);

            // Controls
            ControlsIconNoGamepad = Get(ResxImg.ControlsIconNoGamepad);
            ControlsIconYesGamepad = Get(ResxImg.ControlsIconYesGamepad);
            ControlsIconNoWebcam = Get(ResxImg.ControlsIconNoWebcam);
            ControlsIconYesWebcam = Get(ResxImg.ControlsIconYesWebcam);
            ControlsIconNoKeyboard = Get(ResxImg.ControlsIconNoKeyboard);
            ControlsIconYesKeyboard = Get(ResxImg.ControlsIconYesKeyboard);
            ControlsIconNoGyro = Get(ResxImg.ControlsIconNoGyro);
            ControlsIconYesGyro = Get(ResxImg.ControlsIconYesGyro);

            // Controls
            CreatorPortraits = Get(ResxImg.CreatorPortraits);

            // Input
            InputKeys = Get(ResxImg.InputKeys);
            InputGamepad = Get(ResxImg.InputGamepad);
            InputTilt = Get(ResxImg.InputTilt);

            // Icons
            IconBomb = Get(ResxImg.IconBomb);
            IconHeart = Get(ResxImg.IconHeart);
            IconBackPressed = Get(ResxImg.IconBackPressed);
            IconBack = Get(ResxImg.IconBack);
            IconMuteMute = Get(ResxImg.IconMuteMute);
            IconMuteMutePressed = Get(ResxImg.IconMuteMutePressed);
            IconMuteUnmute = Get(ResxImg.IconMuteUnmute);
            IconMuteUnmutePressed = Get(ResxImg.IconMuteUnmutePressed);
            IconClose = Get(ResxImg.IconClose);
            IconClosePressed = Get(ResxImg.IconClosePressed);
        }

        static Texture2D Get(string path)
        {
            return Texture2D.FromStream(graphics, TitleContainer.OpenStream(path));
        }

        static Texture2D Get(string path, int width, int height, bool zoom)
        {
            return Texture2D.FromStream(graphics, TitleContainer.OpenStream(path), width, height, zoom);
        }
    }
}
